package com.estock.common.model.task.enums;


public enum TaskRunStatus {
	NEW(0, "New"), STARTED(1, "Started"), FINISHED(2, "Finished"), ERROR(3, "Error");
	
	private int runStatus;
	private String desc;
	
	TaskRunStatus(int runStatus, String desc) {
		this.runStatus = runStatus;
		this.desc = desc;
	}
	
	public int getRunStatus() {
		return this.runStatus;
	}
	
	public String getDesc() {
		return desc;
	}

	public static String getDescByRunStatus(int runStatus) {
		if (TaskRunStatus.NEW.runStatus == runStatus) {
			return TaskRunStatus.NEW.desc;
		} else if (TaskRunStatus.STARTED.runStatus == runStatus) {
			return TaskRunStatus.STARTED.desc;
		} else if (TaskRunStatus.FINISHED.runStatus == runStatus) {
			return TaskRunStatus.FINISHED.desc;
		} else if (TaskRunStatus.ERROR.runStatus == runStatus) {
			return TaskRunStatus.ERROR.desc;
		}
		throw new RuntimeException("Unsupported task runStatus.");
	}
	
}
